#ifndef _DLM_COORDINATOR_
#define _DLM_COORDINATOR_

#include "dlm.h"
#include <vector>
#include <sstream>

class DLM_Coordinator
{
	enum { WRONG_LOCK_NAME = -1 };
	
public:
	DLM_Coordinator();

	/**
	* Main loop
	*/
	void run(std::ostream &);
	
private:	
	void do_quit() const;
	void do_pids() const;
	void do_help() const;
	void do_lock(std::stringstream& ss, int argc) const;
	void do_unlock(std::stringstream& ss, int argc) const;
	void do_trylock(std::stringstream& ss, int argc) const;
	
	void wrong_command() const;
	
	int word_count(const std::string& line) const;
	
	int get_lock_num(const std::string& name) const;
};

#endif
